package leetcode.ge100;

class Solution_238 {
	public static void main(String[] args) {
		int[] nums = { 1, 2, 3 };
		productExceptSelf(nums);
	}

	public static int[] productExceptSelf(int[] nums) {
		int l = nums.length;
		int[] left = new int[l];
		int[] right = new int[l];
		left[0] = 1;
		right[l - 1] = 1;
		for (int i = 1; i < l; i++) {
			left[i] = left[i - 1] * nums[i - 1];
			right[l - i - 1] = right[l - i] * nums[l - i];
		}
		for (int i = 0; i < l; i++) {
			nums[i] = left[i] * right[i];
		}
		return nums;
	}

}
